package com.beiding.jsonanalyzer.analyze.query.queryfunc;

import com.beiding.jsonanalyzer.analyze.query.Comparator;
import com.beiding.jsonanalyzer.analyze.query.ComparatorResult;

/**
 * @author 丁常磊
 * @date 2022/6/27 10:50
 */

public class Typeof implements Comparator {

    @Override
    public ComparatorResult compare(Object keyValue, Object valueValue) {

        if (!(valueValue instanceof Class)) {
            return null;
        }

        Class type = (Class) valueValue;

        return type.isInstance(keyValue) ? ComparatorResult.TRUE : ComparatorResult.FALSE;
    }

    @Override
    public String toString() {
        return "typeof";
    }
}
